/**
 * Created by: "Nicola Garegnani"
 * 25/feb/2013
 */
package com.hexworks.main;

import java.util.Hashtable;

public class Combinatoria {

	// grandezza della regione in relazione ai numeri m
	// nel caso con 4 abbiamo tutte le 24 permutazioni?
	private static final int A = 95;
	private static final double B = Math.E / A;
	private static final double C = Math.PI * A;
	private static final int N = 4;

	private static Hashtable<String, String> counterString = new Hashtable<String, String>();

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		int incrementChecker = 0;

		int a,m;
		double b,c,B,C;
		StringBuilder composite = new StringBuilder();
		String appender = new String();

		int A = 5;

		do {
			A = A + 1;
			B = Math.E / A;
			C = Math.PI * A;

			m = 0;

			do {
				m = m + 10;
				a = A;
				c = C;

				for (b = A + Math.E / A; b <= (m * C); b = b + B) {
					if (b > c && b > a) {
						if (a < c) {
							appender = "acb";
						} else {
							appender = "cab";
						}
						c += C;
						a++;
					} else if (b > c) {
						appender = "cb";
						c += C;
					} else if (b > a) {
						appender = "ab";
						a++;
					} else {
						appender = "b";
					}
//					System.out.println("passo" + r + "B" + b + " a= " + (a - 1) + " c= " + c + " " + appender);
					composite.append(appender);
				}
//				System.out.println("With A_n=" + A + " , B_n=" + B + " , C_n=" + C + " " + (C / B)
//						+ " String length: " + composite.length());
				// System.out.println(composite);
				String working = composite.toString();
				composite.delete(0, working.length());

				for (int i = 1; i <= N; i++) {
					for (int j = 0; j < working.length() - i; j++) {
						if (!counterString.containsKey(working.substring(j, j + i)))
							counterString.put(working.substring(j, j + i), working.substring(j, j + i));
					}
					for (String s : counterString.keySet()) {
						System.out.println(s);
					}
					System.out.println("k=" + i + " abbiamo " + counterString.size()
							+ " stringhe diverse\tDifference: \t" + (counterString.size() - incrementChecker));
					incrementChecker = counterString.size();
					counterString.clear();
				}
				
			} while (incrementChecker != 21 && m < (Integer.MAX_VALUE / 100));
			float rapport = (float) ((m * C) / A);
//			System.out.println("Con m=" + A + " la regione è " + rapport * A + "(" + (m - 10) + ") rapporto="
//					+ rapport);
//			System.out.print("("+A + ", " + rapport * A+") " );
//			if (m%50==0)
//				System.out.println();

		} while (true);
	}
}
